﻿using System;
using System.Threading.Tasks;

namespace vBridge.Design.Mvvm.Command
{
    /// <summary>
    /// A command whose sole purpose is to relay its functionality to other objects by invoking delegates. The default return value for the CanExecute method is 'true'.
    /// The command execution is invoked asynchronously.
    /// </summary>
    public class RelayCommandAsync : RelayCommand
    {
        public RelayCommandAsync(Action action, Func<Boolean> predicate)
            : base(action, predicate)
        {
        }

        public RelayCommandAsync(Action action)
            : base(action)
        {
        }

        public override void Execute(Object parameter)
        {
            Task.Run(() => base.Execute(parameter));
        }
    }
}